//
//  HNNormalMsgController.m
//  JHFBaseProject
//
//  Created by 朱传正 on 2017/1/4.
//  Copyright © 2017年 好牛. All rights reserved.
//

#import "HNNormalMsgController.h"
#import "HNProofIdentityController.h"
#import "HNChoiceViewController.h"

@interface HNNormalMsgController ()<HNChoiceViewControllerDelegate>

@end

@implementation HNNormalMsgController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:NO];
    
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (IBAction)backAction:(UIButton *)sender {
      [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)choiceHistoryAction:(UIButton *)sender {
    HNChoiceViewController *normalMsgVC = [[HNChoiceViewController alloc]init];
    normalMsgVC.delegate = self;
    normalMsgVC.choiceValue = @"hospital";
    [self.navigationController pushViewController:normalMsgVC animated:YES];
    
}


- (IBAction)choiceDepartmentAction:(UIButton *)sender {
    HNChoiceViewController *normalMsgVC = [[HNChoiceViewController alloc]init];
    normalMsgVC.delegate = self;
    normalMsgVC.choiceValue = @"department";
    [self.navigationController pushViewController:normalMsgVC animated:YES];
}


- (IBAction)choiceRoleAction:(UIButton *)sender {
    HNChoiceViewController *normalMsgVC = [[HNChoiceViewController alloc]init];
    normalMsgVC.delegate = self;
    normalMsgVC.choiceValue = @"professionalTitle";
    [self.navigationController pushViewController:normalMsgVC animated:YES];
}



- (IBAction)nextAction:(UIButton *)sender {
    
    if ([AppConfig isNULL:_realName.text]) {
        [self showHint:@"请输入真实姓名"];
        return;
    }
    if ([AppConfig isNULL:_hospital
         .text]) {
        [self showHint:@"请输入医院名称"];
        return;
    }
    if ([AppConfig isNULL:_department.text]) {
        [self showHint:@"请输入科室名"];
        return;
    }
    if ([AppConfig isNULL:_professionalTitle.text]) {
        [self showHint:@"请输入职称"];
        return;
    }
    if ([AppConfig isNULL:_telOne.text] || [AppConfig isNULL:_telTwo.text]) {
        [self showHint:@"请输入电话号码"];
        return;
    }
    if ([AppConfig isNULL:_flag1 .text]) {
        [self showHint:@"请输入医生特长及介绍"];
        return;
    }
  
    
    
    HNProofIdentityController *normalMsgVC = [[HNProofIdentityController alloc]init];
    
    normalMsgVC.username = _username;
    normalMsgVC.password = _password;
    normalMsgVC.captcha = _captcha;
    
    normalMsgVC.realName = _realName.text;
    normalMsgVC.hospitalId = _hospitaiId;
    normalMsgVC.departmentId = _departmentId;
    normalMsgVC.professionalTitleId = _professionalTitleId;
    normalMsgVC.telephone = [NSString stringWithFormat:@"%@-%@",_telOne.text,_telTwo.text];
    normalMsgVC.flag1 = _flag1.text;
    
    [self.navigationController pushViewController:normalMsgVC animated:YES];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    _hospital.text = @"";
    _department.text = @"";
    _professionalTitle.text = @"";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - HNChoiceViewControllerDelegate
-(void)HNChoiceViewControllerSetHospitai:(NSDictionary *)hospital{
    _hospital.text = [NSString stringWithFormat:@"%@", [hospital objectForKey:@"name"]];
    _hospitaiId = [NSString stringWithFormat:@"%@", [hospital objectForKey:@"id"]];
}

-(void)HNChoiceViewControllerSetDepartment:(NSDictionary *)department{
     _department.text = [NSString stringWithFormat:@"%@", [department objectForKey:@"name"]];
      _departmentId = [NSString stringWithFormat:@"%@", [department objectForKey:@"id"]];
}

-(void)HNChoiceViewControllerSetProfessionalTitle:(NSDictionary *)ProfessionalTitle{
    _professionalTitle.text = [NSString stringWithFormat:@"%@", [ProfessionalTitle objectForKey:@"name"]];
      _professionalTitleId = [NSString stringWithFormat:@"%@", [ProfessionalTitle objectForKey:@"id"]];
}

@end
